package main.canvas;

import javax.swing.*;
import java.awt.*;

public class RiverCanvas extends JPanel {

    private CanvasComponent root;

    public RiverCanvas(CanvasComponent root) {
        this.root = root;
    }

    @Override
    public void paint(Graphics g) {
//        super.paint(g);
        draw((Graphics2D) g, root);
    }

    private void draw(Graphics2D g, CanvasComponent component) {
        component.draw(g);
        for (CanvasComponent child : component.getChildren()) {
            draw(g, child);
        }
    }
}
